package com.freshmarket.freshmarket.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.freshmarket.freshmarket.dao.ProductMapper;
import com.freshmarket.freshmarket.entity.Product;
import com.freshmarket.freshmarket.service.IProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author Squirrel
 * @since 2020-09-04
 */
@Service
public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> implements IProductService {
@Autowired
private ProductMapper productMapper;
    @Override
    public List<Product> selectProduct(String productType) {
    List<Product> products =productMapper.selectProduct(productType);

        return products;
    }

    @Override
    public List<Product> selectAllProduct() {
        List<Product> list=productMapper.selectAll();
        return list;
    }

    @Override
    public IPage<Product> selectp(int pageIndex, int pageSize, String productName, String productType) {
        Page<Object> objectPage = new Page<>(pageIndex, pageSize);
        IPage<Product> iPage=productMapper.queryProduct(objectPage,productName,productType);
        return iPage;
    }
}
